package indexes;

import java.util.ArrayList;
/**
 * A PlayerName is the relationship between a player's name
 * and any records pertaining to that player.
 * @author bfults (Brian Fults - 905084698)
 *
 */
public class PlayerName implements Comparable<PlayerName>, AggregateRecords<Long>
{
    ArrayList<Long> offsets = new ArrayList<Long>();
    String name;
   
    /**
     * Even though we know there will only be one offset on construction,
     * we need a list for adding more later.
     * @param name player's name
     * @param offset first offset found of this player.
     */
    public PlayerName(String name, Long offset)
    {
        this.name = name;
        offsets.add(offset);
    }

    @Override
    /**
     * Players are comparable on name only, not on offsets.
     */
    public int compareTo( PlayerName otherPlayer )
    {
        return this.name.compareTo(otherPlayer.getName());
    }

    @Override
    public void addValue( Long toAdd )
    {
        offsets.add( toAdd );
        
    }
    
    @Override
    public Long getRecord()
    {
        return offsets.get( 0 );
    }
    
    /**
     * Returns the name associated with this relationship.
     * @return the name
     */
    public String getName()
    {
        return this.name;
    }
    
    @Override
    public ArrayList<Long> getRecords()
    {
        return this.offsets;
    }
    
    public String toString()
    {
        return this.name + this.getRecords();
    }

}
